<!DOCTYPE html>
<html>
    <head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>管理员管理- 添加管理员</title>
	<meta name="keywords" content="">
	<meta name="description" content="">
	<link rel="shortcut icon" href="../favicon.ico">
	<link href="__PUBLIC__/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
	<link href="__PUBLIC__/css/font-awesome.css?v=4.4.0" rel="stylesheet">
	<link href="__PUBLIC__/css/plugins/iCheck/custom.css" rel="stylesheet">
	<link href="__PUBLIC__/css/animate.css" rel="stylesheet">
	<link href="__PUBLIC__/css/style.css?v=4.1.0" rel="stylesheet">
	<link rel="stylesheet" href="__PUBLIC__/css/liandong.css"/>
	<link href="__PUBLIC__/Widget/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
	<script src="__PUBLIC__/js/plugins/layer/laydate/laydate.js"></script>
    </head>
    <body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
	    <div class="row">
		<div class="col-sm-12">
		    <div class="ibox float-e-margins">
			<div class="ibox-title">
			    <h5>管理员管理- <small><{$columnname}></small>
			    </h5>
			</div>
			<div class="ibox-content">
			    <form method="post" class="form-horizontal" onsubmit="return false">
				<if condition="$app_code eq ''">
<!--				    <div class="form-group">
					<label class="col-sm-2 control-label">项目</label>
					<div class="col-sm-10">
					    <select class="form-control" name="ddlapp" id="ddlapp">
						<option value="" selected="selected">-请选择项目-</option>
						<volist name="apparr" id="apparr">
						    <option value="<{$apparr.app_flag}>" <if condition="$apparr.app_flag eq $appcode">selected</if>><{$apparr.app_name}></option>
						</volist>
					    </select>
					</div>
				    </div>-->
				</if>
				<div class="form-group">
				    <label class="col-sm-2 control-label">*管理员账号</label>
				    <div class="col-sm-10">
					<input type="text" class="form-control" value="<{$username}>" placeholder="请输入用户名/手机号码" id="txtusername">
				    </div>
				</div>
				<if condition="$id gt 0">
				    <div class="form-group">
					<label class="col-sm-2 control-label">密码</label>
					<div class="col-sm-10">
					    <div class="checkbox i-checks">
						<label for="ckbpwdreset" style="padding: 0;">
						    <div class="icheckbox_square-green"><input type="checkbox" id="ckbpwdreset" name="ckbpwdreset" value="1" style="position: absolute; opacity: 0;" /></div><i></i>重置密码
						</label>
						<span style="color: #999;">（勾选，密码将初始化为 123456）</span>
					    </div>
					    <!--					    <input type="password" class="form-control" placeholder="为空表示不修改" id="txtpassword">-->
					</div>
				    </div>
				    <else/>
				    <div class="form-group">
					<label class="col-sm-2 control-label">*初始密码</label>
					<div class="col-sm-10 control-label" style="text-align: left;">
					    123456<span style="color: #999;">（请登录后重置密码）</span>
					</div>
				    </div>
				</if>
				<div class="form-group">
				    <label class="col-sm-2 control-label">*管理员角色</label>
				    <div class="col-sm-10">
					<select class="form-control" id="ddlrole">
					    <option value="0">-请选择角色-</option>
					    <volist name="data" id="vo">
						<option value="<{$vo.id}>" <{$vo.role_selected}>><{$vo.name}></option>
					    </volist>
					</select>
				    </div>
				</div>

					<div class="form-group">
						<label class="col-sm-2 control-label">*分销商代码ID</label>
						<div class="col-sm-10">
							<select class="form-control" id="fxcode">
								<option value="0">-分销商ID-</option>
								<volist name="fxcode" id="vo">
									<option value="<{$vo.code}>" ><{$vo.code}></option>
								</volist>
							</select>
						</div>
					</div>

				<div class="hr-line-dashed"></div>
				<div class="form-group">
				    <label class="col-sm-2 control-label">姓名</label>
				    <div class="col-sm-10">
					<input type="text" class="form-control" value="<{$name}>" placeholder="请输入姓名" id="txtname">
				    </div>
				</div>
				<div class="form-group">
				    <label class="col-sm-2 control-label">手机号码</label>
				    <div class="col-sm-10">
					<input type="text" class="form-control" value="<{$phone}>" placeholder="请输入手机号码" id="txtphone">
				    </div>
				</div>
				<if condition="$id gt 0">
				    <div class="form-group">
					<label class="col-sm-2 control-label">状态</label>
					<div class="col-sm-10 control-label" style="text-align: left;">
					    <{$state}>
					</div>
				    </div>
				    <div class="form-group">
					<label class="col-sm-2 control-label">创建时间</label>
					<div class="col-sm-10 control-label" style="text-align: left;">
					    <{$ctime}>
					</div>
				    </div>
				</if>
				<div class="hr-line-dashed"></div>
				<div class="form-group">
				    <div class="col-sm-4 col-sm-offset-2">
					<button class="btn btn-primary" type="button" onclick="admin_add_submit(this)"><{$btnname}></button>&nbsp;&nbsp;&nbsp;
					<button class="btn btn-white" type="reset">重置</button>
				    </div>
				</div>
			    </form>

			</div>
		    </div>
		</div>
	    </div>
	</div>
	<!--  全局js -->
	<script src="__PUBLIC__/js/jquery.min.js?v=2.1.4"></script>
	<script src="__PUBLIC__/js/bootstrap.min.js?v=3.3.6"></script>
	<!-- 自定义js -->
	<script src="__PUBLIC__/js/content.js?v=1.0.0"></script>
	<script src="__PUBLIC__/js/plugins/layer/layer.min.js"></script>
	<script src="__PUBLIC__/js/liandong.js"></script> 
	<script type="text/javascript" src="__PUBLIC__/Widget/webuploader/0.1.5/webuploader.min.js"></script>
	<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
	<!-- iCheck -->
	<script src="__PUBLIC__/js/plugins/iCheck/icheck.min.js"></script>
	<script>
					    $(document).ready(function () {
						$('.i-checks').iCheck({
						    checkboxClass: 'icheckbox_square-green',
						    radioClass: 'iradio_square-green',
						});
					    });
	</script>
	<script>
	    var labname = "<{$btnname}>";
	    var adminaddsubmit = "<{:U('adminaddsubmit','','shtml')}>";
	    var adminlist = "<{:U('adminlist','','shtml')}>";
	    function admin_add_submit(obj) {
		var $obj = $(obj);
		var $ddlapp = $('#ddlapp');
		var $txtusername = $('#txtusername');
		var $ckbpwdreset = $('#ckbpwdreset');
		var $ddlrole = $('#ddlrole');
		var $txtname = $('#txtname');
		var $txtphone = $('#txtphone');
		var id = "<{$id}>";
		var username = $txtusername.val();
		var pwdreset = $ckbpwdreset.prop('checked') ? '1' : '0';
		var appcode = $ddlapp.val();
		var roleid = $ddlrole.val();
		var name = $txtname.val();
		var phone = $txtphone.val();
		var code = $("#fxcode").val();
		if (username == "") {
		    layer.alert('账号不能为空！\r\n', {title: '提示框', icon: 0});
		    //						    $txtusername.focus();
		    return false;
		}
		if (!(roleid > 0)) {
		    layer.alert('角色不能为空！\r\n', {title: '提示框', icon: 0});
		    //						    $ddlrole.focus();
		    return false;
		}
		if (phone != "" && !(/^1[34578]{1}\d{9}$/.test(phone))) {
		    layer.alert('手机号码格式不正确！\r\n', {title: '提示框', icon: 0});
		    //						    $txtphone.focus();
		    return false;
		}
//		$obj.html(labname + '中…').removeClass('btn-primary').unbind('click').removeAttr('onclick');
		layer.confirm('确定<{$btnname}>该管理员吗？', function (index) {
		    layer.close(index);
		    //加载loading层
		    var loading = layer.load(1, {
			shade: [0.1, '#fff'] //0.1透明度的白色背景
		    });
		    $.post(adminaddsubmit, {'app_code': appcode,'fxcode':code, 'id': id, 'username': username, 'pwdreset': pwdreset, 'roleid': roleid, 'name': name, 'phone': phone},
			    function (data) {
				if (data.ret == '1001') {
				    layer.close(loading);
				    layer.msg(data.code, {icon: 6, time: 1000});
				    setTimeout(function () {
					window.location.href = adminlist;
				    }, 1000);
				} else {
				    layer.close(loading);
				    layer.msg(data.code, {icon: 5, time: 1000});
				    $obj.html(labname).addClass('btn-primary').attr('onclick', 'admin_add_submit(this)');
				}
			    }, 'json');
		});
	    }

	</script>
    </body>
</html>
